package demo.engine.template.thymeleaf;

import java.time.LocalDate;
import java.util.Date;

import org.junit.Test;
import org.thymeleaf.EngineConfiguration;
import org.thymeleaf.TemplateSpec;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.templatemode.TemplateMode;
import org.thymeleaf.templateresolver.StringTemplateResolver;

public class ThymeleafDemo {

    @Test
    public void test1() {
        org.springframework.web.servlet.resource.ResourceUrlEncodingFilter a = null;
        StringTemplateResolver resolver = new StringTemplateResolver();
        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
        templateEngine.setTemplateResolver(resolver);
        Context context = new Context();
        context.setVariable("today", LocalDate.now());
        context.setVariable("time", new Date());
        String str = templateEngine.process("<p>Today is: <span th:text=\"${today}\">13 february 2011</span>.</p>",
                context);
        System.out.println(str);
        System.out.println(templateEngine.process("Today is: [(${today})] , [(${time})] , hello [(${name})]", context));

    }
}
